<?php
namespace Nawa\MedicalStudy;
/**
 * Medical Study Metadata Object.
 *
 * It represant additionnal attributes that can be added from 
 * the administratoin screens on the flow
 *
 * @author Xavier VILAIN
 * @package Nawa\MedicalStudy
 *
 * @property int	$msid			MS id (12)
 * @property string $metadata_name	Name
 * @property string $value			Json Encode Value
 *
 */
class Metadata extends \Fox\Object {
	/**
	 * 
	 * Reverse link to medical study
	 * @var string
	 */
	const LINK_MEDICAL_STUDY = 'medicalStudy';
	
	/**
	 * Check List.
	 * @var string
	 */
	const CHECKLISTS = 'checklists';
	
	/**
	 * Parse Metadata to an array
	 * @return array
	 */
	public function parse($direct = false) {
		$name = $this->metadata_name;
		$value = $this->value;
		if(!empty($value)) {
			$data[$name] = json_decode($value,true);
		} else {
			$data[$name] = array();
		}
		if($direct) {
			return $data[$name];
		}
		return $data;
	}
	
	/**
	 * 
	 * Enter description here ...
	 */
	public function format() {
		
	}
}
\Fox\Dao::infos(Metadata::className(),new \Fox\Object\Info('ms_metadatas', \Fox\Databases::DB_APP));